package org.irenty;

import java.util.ArrayList;
import java.util.List;

import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlTableDataCell;

public class BetfairStatisticsScrapper {
    private final ScreenScrapper scrapper;
    private static final String PAGE_URL = "http://www.stats.betradar.com/statistics/betfaircom/main.php?page=guth_statistics_tablecontents&tableid=5337&language=en&showtype=1&tabletype=1&round=1";
    
    public BetfairStatisticsScrapper() {
        this.scrapper = new ScreenScrapper();
    }
    
    public List<String> getTeamNames() {
        HtmlPage page = scrapper.getPage(PAGE_URL);
        List<String> teams = new ArrayList<String>();
        List<HtmlTableDataCell> elements = (List<HtmlTableDataCell>) page.getByXPath("//*[@class=\"table_content\"]/tbody/tr/td[3]");
        for (HtmlTableDataCell c : elements) {
            teams.add(c.getFirstChild().asText());
        }

        return teams;
    }
}
